﻿using System;
using Common.Logging;

namespace NPMonitor.Web
{
    public partial class Error : System.Web.UI.Page
    {
        private ILog logger = LogManager.GetCurrentClassLogger();
        protected void Page_Load(object sender, EventArgs e)
        {
            Exception exception = Context.Server.GetLastError();

            if (exception != null)
            {
                string errorInfo =
                   "<br/>Offending URL: " + Request.Url.ToString() +
                   "<br/>Source: " + exception.Source +
                   "<br/>Message: " + exception.Message +
                   "<br/>Stack trace: " + exception.StackTrace +
                   "<br/>Inner Exception: " + (exception.InnerException != null ? exception.InnerException.Message : string.Empty);

                lblMessage.Text = errorInfo;

                logger.Error(errorInfo, exception);

                Server.ClearError();
            }
        }
    }
}